<?php

include_once '../tools/common.php';
include_once '../tools/DbTools.php';
$is_login = getLoginStatus();
if(!$is_login){
    echo '尚未登入，<a href="../user/loginUi.php">请登入</a>';
    die;
}else{
    session_start();
    $userInfo = $_SESSION[$_COOKIE['Token']];
    $realName = $userInfo['realName'];
    $cardId = $userInfo['CardId'];

    DbTools::InitDb();
    $sql = "select * from bankcard where AccountId = 
    (select AccountId from accountinfo where RealName = '$realName' and CardId != $cardId) ";
    $result = DbTools::select($sql);
    //关闭连接
    DbTools::close();

    if (empty($result)){
        echo '<p><a href="../user/userInfo.php">回到用户中心</a></p><br>';
        echo '您账户下只存在一张卡！！';
        die;
    }
    echo '<p><a href="../user/userInfo.php">回到用户中心</a></p><br>';

    for ($i=0;$i<count($result);$i++)
    {
        echo '第'.($i+1).'张卡';
        echo '<br>';
        echo '卡ID:'.$result[$i]['CardId'];
        echo '<br>';
        echo '卡号:'.$result[$i]['CardNo'];
        echo '<br>';
        echo '用户ID:'.$result[$i]['AccountId'];
        echo '<br>';
        echo '密码:'.$result[$i]['CardPwd'];
        echo '<br>';
        echo '余额:'.$result[$i]['CardMoney'];
        echo '<br>';
        echo '状态:'.$result[$i]['CardState'];
        echo '<br>';
        echo '建卡时间:'.$result[$i]['CardTime'];
        echo '<br>';
        echo '<br>';
    }
}
